//
//  ContentView.swift
//  Casecord
//
//  Created by baozi on 2024/1/3.
//

import SwiftUI

struct ContentView: View {
    @EnvironmentObject var userService: UserService
    
    init() {
        let navbarAppearance = UINavigationBarAppearance()
        navbarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor(Theme.color.title)]
        navbarAppearance.titleTextAttributes = [.foregroundColor: UIColor(Theme.color.title)]
        navbarAppearance.backgroundColor = UIColor(Theme.color.primaryBackgroundColor)
        UINavigationBar.appearance().standardAppearance = navbarAppearance
        UINavigationBar.appearance().compactAppearance = navbarAppearance
        UINavigationBar.appearance().scrollEdgeAppearance = navbarAppearance
    }
    
    var body: some View {
        switch userService.loginStep {
        case .launch:
            LaunchPage()
                .transition(.opacity)
        case .login:
            MainPage()
                .transition(.opacity)
        case .logout:
            LoginPage()
                .transition(.opacity)
        }
    }
}

#Preview {
    ContentView()
}
